<?php
// Checks if user is logged in else redirect back to startpage
if(!isset($_SESSION["valid_email"])) {
	header("Location: index.php");
}

// Gets the current name of the php page
$currentFile = $_SERVER["SCRIPT_NAME"];
$parts = Explode('/', $currentFile);
$currentFile = $parts[count($parts) - 1];
$currentFile = str_replace('.php', '', $currentFile);

// Checks if the user has rights to access the current page
if(isset($_SESSION[$currentFile])) {
	if($_SESSION[$currentFile] != 1) {
		header("Location: index.php");
	}
}
?>

